interplot

Create matplotlib/plotly hybrid plots with a few lines of code.

It combines the best of the matplotlib and the plotly worlds through a unified, flat API. All the necessary boilerplate code is contained in this module.

Currently supported:

  • line plots (scatter)

  • line fills

  • histograms

  • heatmaps

  • boxplot

  • linear regression

  • text annotations

  • 2D subplots

  • color cycling

Resources

Licence

License: GPL v3

Demo

View on NBViewer:

NBViewer

Try on Binder:

Binder

Install

pip install interplot

dev installation

  1. git clone https://github.com/janjoch/interplot

  2. cd interplot

  3. pip install -e .

Documentation and API reference

Example

>>> interplot.line([0,4,6,7], [1,2,4,8])
>>> interplot.line(
...     x=[0,4,6,7],
...     y=[1,2,4,8],
...     interactive=False,
...     color="red",
...     title="matplotlib static figure",
...     xlabel="abscissa",
...     ylabel="ordinate",
... )
[matplotlib plot "Normally distributed Noise]
>>> fig = interplot.Plot(
...     interactive=True,
...     title="Everything Under Control",
...     fig_size=(800, 500),
...     rows=1,
...     cols=2,
...     shared_yaxes=True,
...     save_fig=True,
...     save_format=("html", "png"),
...     # ...
... )
... fig.add_hist(np.random.normal(1, 0.5, 1000), row=0, col=0)
... fig.add_boxplot(
...     [
...         np.random.normal(20, 5, 1000),
...         np.random.normal(40, 8, 1000),
...         np.random.normal(60, 5, 1000),
...     ],
...     row=0,
...     col=1,
... )
... # ...
... fig.post_process()
... fig.show()
saved figure at Everything-Under-Control.html
saved figure at Everything-Under-Control.png
>>> @interplot.magic_plot
... def plot_lines(samples=100, n=10, label="sigma={0}, mu={1}", fig=None):
...     """
...     Plot Gaussian noise.
...
...     The function must accept the `fig` parameter from the decorator.
...     """
...     for i in range(1, n+1):
...         fig.add_line(
...             np.random.normal(i*10,i,samples),
...             label=label.format(i, i*10),
...         )
>>> plot_lines(samples=200, title="Normally distributed Noise")
>>> plot_lines(
...     samples=200, interactive=False, title="Normally distributed Noise")
[matplotlib plot "Normally distributed Noise]

Indices and tables